package com.hanxiaozhang.system.dao;

import com.hanxiaozhang.system.entity.UserJobEntity;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * 用户岗位关联表
 *
 * @author hanxiaozhang
 * @email hanxiaozhang2018@sina.com
 * @date 2021-03-30
 */
@Mapper
public interface UserJobDao {

	UserJobEntity get(Long userJobId);
	
	List<UserJobEntity> list(Map<String, Object> map);

	int save(UserJobEntity userJob);
	
	int update(UserJobEntity userJob);

	int batchSave(List<UserJobEntity> roleMenus);



	/**
	 * 通过部门id查询
	 *
	 * @param jobId
	 * @return
	 */
	@Select("SELECT * FROM sys_user_job WHERE job_id = #{jobId} AND  del_flag=0")
	List<UserJobEntity> listByJobId(@Param("jobId") Long jobId);

	/**
	 * 通过用户id查询
	 *
	 * @param userId
	 * @return
	 */
	@Select("SELECT * FROM sys_user_job WHERE user_id = #{userId} AND  del_flag=0")
	List<UserJobEntity> listByUserId(@Param("userId") Long userId);

	/**
	 * 通过部门id集合查询
	 *
	 * @param jobIds
	 * @return
	 */
	List<UserJobEntity> listByJobIds(@Param("jobIds") List<Long> jobIds);

	/**
	 * 通过用户id集合查询
	 *
	 * @param userIds
	 * @return
	 */
	List<UserJobEntity> listByUserIds(@Param("userIds") List<Long> userIds);


	/**
	 * 通过用户id删除
	 *
	 * @param userId
	 * @return
	 */
	@Update("UPDATE sys_user_job SET del_flag = 1  WHERE user_id = #{userId} AND  del_flag = 0")
	int removeByUserId(@Param("userId") Long userId);

	/**
	 * 通过用户id集合批量删除
	 *
	 * @param userIds
	 * @return
	 */
	int batchRemoveByUserIds(Long[] userIds);

}
